﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using Toom.CellularAutomata.Debug;
using Toom.CellularAutomata.Common;


namespace Toom.CellularAutomata.GUI
{
	public partial class FormSettings : Form
	{
		public FormSettings()
		{
			InitializeComponent();
		}

		private void FormSettings_Load( object sender, EventArgs e )
		{
			LoadSettingsToDisplay();
		}

		private void buttonApply_Click( object sender, EventArgs e )
		{
			SaveSettings();
			LoadSettingsToDisplay();
		}

		private void buttonReLoad_Click( object sender, EventArgs e )
		{
			LoadSettingsToDisplay();
		}

		private void buttonClose_Click( object sender, EventArgs e )
		{
			this.Close();
		}

		private void linkLabel1_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e )
		{
			System.Diagnostics.Debugger.Break();
		}



		// HELPERS
		private void LoadSettingsToDisplay()
		{
			checkboxUseMultipleCPUs.Checked = CASettings.UseMultiCPU;
			checkboxUseLifeOpt.Checked = CASettings.UseNeighborOpt;
		}

		private void SaveSettings()
		{
			CASettings.UseMultiCPU    = checkboxUseMultipleCPUs.Checked;
			CASettings.UseNeighborOpt = checkboxUseLifeOpt.Checked;

			// make sure they saved
			if ( CASettings.UseMultiCPU != checkboxUseMultipleCPUs.Checked )
				MessageBox.Show( this, "UsemultiCPU not saved correctly" );
			if ( CASettings.UseNeighborOpt != checkboxUseLifeOpt.Checked )
				MessageBox.Show( this, "UsemultiCPU not saved correctly" );
		}




	}
}
